<%-- 
    Document   : display_news
    Created on : 11 Jul, 2012, 12:05:50 AM
    Author     : bharat
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<!DOCTYPE html>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="./css/maincss.css">
        <link rel="stylesheet" type="text/css" href="./css/myaccountcss.css">
        <title>Online College Magazine</title>
        <script type="text/javascript">

            var rowVisible = false;

            function toggleDisplay(tbl) {
                var tblRows = tbl.rows;
                for (i = 0; i < tblRows.length-1; i++) {
                    if (tblRows[i].className != "headerRow") {
                        tblRows[i].style.display = (rowVisible) ? "none" : "table-row";
                    }
                }
                rowVisible = !rowVisible;
            }

        </script>

    </head>
    <body>
        <div class="container">
            <div class="header">
                ONLINE COLLEGE MAGAZINE
            </div>
            <div class="navigation_menu">
                <%@include file="navigationmenu.jsp"%>
            </div>

            <div class="slab">

                <%
                    String nid = request.getParameter("nid");

                    Connection con = null;
                    PreparedStatement pstmt = null;
                    ResultSet rs = null;

                    try {

                        Class.forName("oracle.jdbc.driver.OracleDriver");
                        con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "aksh", "aksh");

                        pstmt = con.prepareStatement("select *from tblnews where news_id=?");
                        pstmt.setString(1, nid);
                        rs = pstmt.executeQuery();
                        for (int i = 0; i < 10; i++) {
                            if (rs.next()) {
                %>
                <table id="theTable<%=i%>" border="1" width="100%">
                    <tr class="headerRow" style="display:table-row;">
                        <td style="font-weight: bold;font-size: 1.3em;text-transform: uppercase;background-color: #74e868 ">
                            <%=rs.getString(2)%>
                        </td></tr>
                    <tr style="display:none;"><td>
                            <%=rs.getString(3)%>
                        </td></tr>
                    <tr>
                        <td>
                            Created On: <%=rs.getString(4)%>
                        </td>
                    </tr>
                </table>
                <div onclick="toggleDisplay(document.getElementById('theTable<%=i%>'))">............click here to read............</div>
                <%
                    }%><br><%
                        }

                    } catch (Exception e) {
                        response.sendError(555, e.getMessage());
                        e.printStackTrace();
                    } finally {
                        if (rs != null) {
                            try {
                                rs.close();
                            } catch (Exception e) {
                                response.sendError(555, e.getMessage());
                            }
                        }
                        if (pstmt != null) {
                            try {
                                pstmt.close();
                            } catch (Exception e) {
                                response.sendError(555, e.getMessage());
                            }
                        }
                        if (con != null) {
                            try {
                                con.close();
                            } catch (Exception e) {
                                response.sendError(555, e.getMessage());
                            }
                        }
                    }
                %>

            </div>

            <div class="login">
                <%@include file="types_anchored.html" %>
            </div>
            <div class="sidebar">
                <table>
                    <tr><td>LATEST NEWS</td></tr><tr><td>&nbsp;&nbsp;</td></tr>
                </table>
                <%@include file="display_news_scroll.jsp" %>
            </div>

            <div class="footer">
                FOOTER
            </div>
        </div>
    </body>
</html>
